<HTML>
<HEAD>
<TITLE>[Chapter 21] java.awt.event Reference</TITLE>
<META NAME="author" CONTENT="John Zukowski">
<META NAME="date" CONTENT="Thu Jul 31 15:21:17 1997">
<META NAME="form" CONTENT="html">
<META NAME="metadata" CONTENT="dublincore.0.1">
<META NAME="objecttype" CONTENT="book part">
<META NAME="otheragent" CONTENT="gmat dbtohtml">
<META NAME="publisher" CONTENT="O'Reilly &amp; Associates, Inc.">
<META NAME="source" CONTENT="SGML">
<META NAME="subject" CONTENT="Java AWT">
<META NAME="title" CONTENT="Java AWT">
<META HTTP-EQUIV="Content-Script-Type" CONTENT="text/javascript">
</HEAD>
<body vlink="#551a8b" alink="#ff0000" text="#000000" bgcolor="#FFFFFF" link="#0000ee">
<script language='JavaScript'>
<!--
if (location.replace) {
 location.replace ('ch21_js.htm');
}
// -->
</script>

<DIV CLASS=htmlnav>
<H1><a href='index.htm'><IMG SRC="gifs/smbanner.gif"
     ALT="Java AWT" border=0></a></H1>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch20_06.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><B><FONT FACE="ARIEL,HELVETICA,HELV,SANSERIF" SIZE="-1">Chapter 21</FONT></B></TD>
<td width=172 align=right valign=top><A HREF="ch21_02.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
</table>

&nbsp;
<hr align=left width=515>
</DIV>
<H1 CLASS=chapter><A CLASS="TITLE" NAME="JAWT-CH-21">21. java.awt.event Reference</A></H1>

<DIV CLASS=htmltoc>

<p>
<b>Contents:</b><br>
<a href='ch21_02.htm'>ActionListener <img src="gifs/bstar.gif" alt="(New)" border=0></a><br>
<a href='ch21_03.htm'>AdjustmentEvent <img src="gifs/bstar.gif" alt="(New)" border=0></a><br>
<a href='ch21_04.htm'>AdjustmentListener <img src="gifs/bstar.gif" alt="(New)" border=0></a><br>
<a href='ch21_05.htm'>ComponentAdapter <img src="gifs/bstar.gif" alt="(New)" border=0></a><br>
<a href='ch21_06.htm'>ComponentEvent <img src="gifs/bstar.gif" alt="(New)" border=0></a><br>
<a href='ch21_07.htm'>ComponentListener <img src="gifs/bstar.gif" alt="(New)" border=0></a><br>
<a href='ch21_08.htm'>ContainerAdapter <img src="gifs/bstar.gif" alt="(New)" border=0></a><br>
<a href='ch21_09.htm'>ContainerEvent <img src="gifs/bstar.gif" alt="(New)" border=0></a><br>
<a href='ch21_10.htm'>ContainerListener <img src="gifs/bstar.gif" alt="(New)" border=0></a><br>
<a href='ch21_11.htm'>FocusAdapter <img src="gifs/bstar.gif" alt="(New)" border=0></a><br>
<a href='ch21_12.htm'>FocusEvent <img src="gifs/bstar.gif" alt="(New)" border=0></a><br>
<a href='ch21_13.htm'>FocusListener <img src="gifs/bstar.gif" alt="(New)" border=0></a><br>
<a href='ch21_14.htm'>InputEvent <img src="gifs/bstar.gif" alt="(New)" border=0></a><br>
<a href='ch21_15.htm'>ItemEvent <img src="gifs/bstar.gif" alt="(New)" border=0></a><br>
<a href='ch21_16.htm'>ItemListener <img src="gifs/bstar.gif" alt="(New)" border=0></a><br>
<a href='ch21_17.htm'>KeyAdapter <img src="gifs/bstar.gif" alt="(New)" border=0></a><br>
<a href='ch21_18.htm'>KeyEvent <img src="gifs/bstar.gif" alt="(New)" border=0></a><br>
<a href='ch21_19.htm'>KeyListener <img src="gifs/bstar.gif" alt="(New)" border=0></a><br>
<a href='ch21_20.htm'>MouseAdapter <img src="gifs/bstar.gif" alt="(New)" border=0></a><br>
<a href='ch21_21.htm'>MouseEvent <img src="gifs/bstar.gif" alt="(New)" border=0></a><br>
<a href='ch21_22.htm'>MouseListener <img src="gifs/bstar.gif" alt="(New)" border=0></a><br>
<a href='ch21_23.htm'>MouseMotionAdapter <img src="gifs/bstar.gif" alt="(New)" border=0></a><br>
<a href='ch21_24.htm'>MouseMotionListener <img src="gifs/bstar.gif" alt="(New)" border=0></a><br>
<a href='ch21_25.htm'>PaintEvent <img src="gifs/bstar.gif" alt="(New)" border=0></a><br>
<a href='ch21_26.htm'>TextEvent <img src="gifs/bstar.gif" alt="(New)" border=0></a><br>
<a href='ch21_27.htm'>TextListener <img src="gifs/bstar.gif" alt="(New)" border=0></a><br>
<a href='ch21_28.htm'>WindowAdapter <img src="gifs/bstar.gif" alt="(New)" border=0></a><br>
<a href='ch21_29.htm'>WindowEvent <img src="gifs/bstar.gif" alt="(New)" border=0></a><br>
<a href='ch21_30.htm'>WindowListener <img src="gifs/bstar.gif" alt="(New)" border=0></a><br>
<p>
<p>
</DIV>

<DIV CLASS=refnamediv>
<H1>ActionEvent <img src="gifs/bstar.gif" alt="(New)" border=0></H1>

<H2>Name</H2>

ActionEvent <img src="gifs/bstar.gif" alt="(New)" border=0>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch21-REFSECT1-AUTOID.1"></A></h2>
</DIV>


<p>
<img align=middle src="./figs/actione.gif" alt="[Graphic: Figure from the text]" width=502 height=52 border=0>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch21-REFSECT1-AUTOID.2">Description</A></h2>

<P CLASS=para>
Action events are fired off when the user performs an action on a component, 
such as pushing a button, double-clicking on a list item, or selecting 
a menu item. There is only one action event type, <tt CLASS=literal>ACTION_PERFORMED</tt>. 

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch21-REFSECT1-AUTOID.3">Class Definition</A></h2>

<DIV CLASS=screen>
<P>
<PRE>
public class java.awt.event.ActionEvent
   extends java.awt.AWTEvent {
  // Constants
  public final static int ACTION_FIRST;
  public final static int ACTION_LAST;
  public final static int ACTION_PERFORMED;
  public final static int ALT_MASK;
  public final static int CTRL_MASK;
  public final static int META_MASK;
  public final static int SHIFT_MASK;
  // Constructors
  public ActionEvent (Object source, int id, String command);
  public ActionEvent (Object source, int id, String command, int modifiers);
  // Instance Methods
  public String getActionCommand();
  public int getModifiers();
  public String paramString();
}
</PRE>
</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch21-REFSECT1-AUTOID.4">Constants</A></h2>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch21-REFSECT2-AUTOID.1">ACTION_FIRST</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch21-REFSECT3-AUTOID.1">public final static int ACTION_FIRST</A></h4>

<P CLASS=para>
Specifies the beginning range of action event ID values. 

</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch21-REFSECT2-AUTOID.2">ACTION_LAST</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch21-REFSECT3-AUTOID.2">public final static int ACTION_LAST</A></h4>

<P CLASS=para>
Specifies the ending range of action event ID values. 

</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch21-REFSECT2-AUTOID.3">ACTION_PERFORMED</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch21-REFSECT3-AUTOID.3">public final static int ACTION_PERFORMED</A></h4>

<P CLASS=para>
The only action event type; it indicates that the user has performed an 
action. 

</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch21-REFSECT2-AUTOID.4">ALT_MASK</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch21-REFSECT3-AUTOID.4">public final static int ALT_MASK</A></h4>

<P CLASS=para>
A constant representing the ALT key. ORed with other masks to form <tt CLASS=literal>modifiers</tt> setting of an <tt CLASS=literal>AWTEvent</tt>. 

</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch21-REFSECT2-AUTOID.5">CTRL_MASK</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch21-REFSECT3-AUTOID.5">public final static int CTRL_MASK</A></h4>

<P CLASS=para>
A constant representing the Control key. ORed with other masks to 
form <tt CLASS=literal>modifiers</tt> setting of an <tt CLASS=literal>AWTEvent</tt>. 

</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch21-REFSECT2-AUTOID.6">META_MASK</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch21-REFSECT3-AUTOID.6">public final static int META_MASK</A></h4>

<P CLASS=para>
A constant representing the META key. ORed with other masks to form <tt CLASS=literal>modifiers</tt> setting of an <tt CLASS=literal>AWTEvent</tt>. 

</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch21-REFSECT2-AUTOID.7">SHIFT_MASK</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch21-REFSECT3-AUTOID.7">public final static int SHIFT_MASK</A></h4>

<P CLASS=para>
A constant representing the Shift key. ORed with other masks to 
form <tt CLASS=literal>modifiers</tt> setting of an <tt CLASS=literal>AWTEvent</tt>. 

</DIV>

</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch21-REFSECT1-AUTOID.5">Constructors</A></h2>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch21-REFSECT2-AUTOID.8">ActionEvent</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch21-REFSECT3-AUTOID.8">public ActionEvent (Object source, int id, String command)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P CLASS=para>
<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>source</I><br>
<DD>

<P CLASS=para>
The object that 
generated the event.

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>id</I><br>
<DD>

<P CLASS=para>
The type ID of the event.

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>command</I><br>
<DD>

<P CLASS=para>
The action command 
string. </DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Constructs an <tt CLASS=literal>ActionEvent</tt> with 
the given characteristics. </DL>
</DIV>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch21-REFSECT3-AUTOID.9">public ActionEvent (Object source, int id, String command, int modifiers)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P CLASS=para>
<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>source</I><br>
<DD>

<P CLASS=para>
The object that 
generated the event.

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>id</I><br>
<DD>

<P CLASS=para>
The type ID of the event.

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>command</I><br>
<DD>

<P CLASS=para>
The action command 
string.

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>modifiers</I><br>
<DD>

<P CLASS=para>
A combination 
of the key mask constants. </DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Constructs an <tt CLASS=literal>ActionEvent</tt> with 
the given characteristics. </DL>
</DIV>

</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch21-REFSECT1-AUTOID.6">Instance Methods</A></h2>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch21-REFSECT2-AUTOID.9">getActionCommand</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch21-REFSECT3-AUTOID.10">public String getActionCommand()</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The action command string for this <tt CLASS=literal>ActionEvent</tt>. 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Generally the action command string is the label of the component that 
generated the event. Also, when localization is necessary, the action command 
string can provide a setting that does not get localized. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch21-REFSECT2-AUTOID.10">getModifiers</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch21-REFSECT3-AUTOID.11">public int getModifiers()</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
A combination of the key mask constants. 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Returns the modifier keys that were held down when this action was performed. 
This enables you to perform special processing if, for example, the user 
holds down Shift while pushing a button. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch21-REFSECT2-AUTOID.11">paramString</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch21-REFSECT3-AUTOID.12">public String paramString()</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
String with current settings of <tt CLASS=literal>ActionEvent</tt>. 

<p>
<DT CLASS=varlistentry>Overrides<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>AWTEvent</tt><tt CLASS=literal>.paramString()</tt> 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Helper method for <tt CLASS=literal>toString()</tt> 
to generate string of current settings. </DL>
</DIV>

</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch21-REFSECT1-AUTOID.7">See Also</A></h2>

<P CLASS=para>
<tt CLASS=literal>ActionListener</tt>, <tt CLASS=literal>AWTEvent</tt>, 
<tt CLASS=literal>String</tt> 

</DIV>


<DIV CLASS=htmlnav>

<P>
<HR align=left width=515>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch21_30.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><a href="index.htm"><img src='gifs/txthome.gif' border=0 alt='Home'></a></td>
<td width=172 align=right valign=top><A HREF="ch21_02.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
<tr>
<td width=172 align=left valign=top>WindowListener <img src="gifs/bstar.gif" alt="(New)" border=0></td>
<td width=171 align=center valign=top><a href="index/idx_a.htm"><img src='gifs/index.gif' alt='Book Index' border=0></a></td>
<td width=172 align=right valign=top>ActionListener <img src="gifs/bstar.gif" alt="(New)" border=0></td>
</tr>
</table>
<hr align=left width=515>

<IMG SRC="gifs/smnavbar.gif" USEMAP="#map" BORDER=0> 
<MAP NAME="map"> 
<AREA SHAPE=RECT COORDS="0,0,108,15" HREF="../javanut/index.htm"
alt="Java in a Nutshell"> 
<AREA SHAPE=RECT COORDS="109,0,200,15" HREF="../langref/index.htm" 
alt="Java Language Reference"> 
<AREA SHAPE=RECT COORDS="203,0,290,15" HREF="../awt/index.htm" 
alt="Java AWT"> 
<AREA SHAPE=RECT COORDS="291,0,419,15" HREF="../fclass/index.htm" 
alt="Java Fundamental Classes"> 
<AREA SHAPE=RECT COORDS="421,0,514,15" HREF="../exp/index.htm" 
alt="Exploring Java"> 
</MAP>
</DIV>

</BODY>
</HTML>
